package jonggyuni.basic;

public class J14_ExtendClass {

	public static void main(String[] args) {
		//객체지향 특성 : 상속
		
		J14SungJuk sj = new J14SungJuk("지현", 99,78,55);
		System.out.println(sj.getTotal());
		J14SungJukExtend sje = new J14SungJukExtend("지현", 99, 78, 55, 34, 12);
		System.out.println(sje.getTotal());
		
		
	}//main

}//class

class J14SungJuk{
	private String name;
	private int kor;
	private int eng;
	private int math;
	
	//생성자	
	public J14SungJuk(String name, int kor, int eng, int math) {
		super();
		this.name = name;
		this.kor = kor;
		this.eng = eng;
		this.math = math;
	}
	//getter,setter
	public int getTotal(){
		return kor+eng+math;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getKor() {
		return kor;
	}

	public void setKor(int kor) {
		this.kor = kor;
	}

	public int getEng() {
		return eng;
	}

	public void setEng(int eng) {
		this.eng = eng;
	}

	public int getMath() {
		return math;
	}

	public void setMath(int math) {
		this.math = math;
	}
	
	
	
}//class sungjuk
class J14SungJuk2{
	private String name;
	private int kor;
	private int eng;
	private int math;
	private int soc;
	private int art;
	
	public int getTotal(){
		return kor+eng+math+soc+art;
	}
}//class SungJuk2

class J14SungJukExtend extends J14SungJuk{
	private int soc;
	private int art;
	
	//생성자
	public J14SungJukExtend(String name, int kor, int eng, int math, int soc,
			int art) {
		super(name, kor, eng, math);
		//super()는 상속관계에서 부모클래스의 생성자를 의미 함
		//따라서, super()는 J14SungJuk의 J14SungJuk(name, kor, eng, math)를 가리킴
		this.soc = soc;
		this.art = art;
	}



	@Override
	public int getTotal() {
		//return kor+eng+math+soc+art;
		return super.getTotal()+soc+art;
		//super.getTotal에는 부모클래스에서 계산한 내용들이 들어 있음
		//super는 상속 관계에서 부모클래스를 의미
		//따라서, J14SungJuk 클래스의 getTotal 메서드를 카리킴
	}



	public int getSoc() {
		return soc;
	}



	public void setSoc(int soc) {
		this.soc = soc;
	}



	public int getArt() {
		return art;
	}



	public void setArt(int art) {
		this.art = art;
	}
	
	
}//class extend J14SungJuk
